package org.ntu.rtsearch.index.model;

public class Field {
	
	private boolean isIndexed;
	
	private boolean isStore;
	
	private String name;
	
	private String value;

	private boolean isAnalyzed;
	

	public Field(String name, String value, Store store, Index index) {
		this.name = name;
		this.value = value;
		this.isIndexed = index.isIndex();
		this.isAnalyzed = index.isAnalyzed();
		this.isStore = store.isStore();
	}
	
	public static enum Store {
		YES {
			public boolean isStore() {
				return true;
			}
		},
		
		NO {
			public boolean isStore() {
				return false;
			}
		};
		
		public abstract boolean isStore();
	}
	
	public static enum Index {
		NO {
			public boolean isIndex() {
				return false;
			}
			
			public boolean isAnalyzed() {
				return false;
			}
		},
		
		ANALYZED {
			public boolean isIndex() {
				return true;
			}
			
			public boolean isAnalyzed() {
				return true;
			}
		},
		
		NO_ANALYZED {
			public boolean isIndex() {
				return true;
			}
			
			public boolean isAnalyzed() {
				return false;
			}
		};
		
		public abstract boolean isIndex();
		public abstract boolean isAnalyzed();
	}

	public synchronized boolean isIndexed() {
		return isIndexed;
	}

	public synchronized void setIndexed(boolean isIndexed) {
		this.isIndexed = isIndexed;
	}

	public synchronized boolean isStore() {
		return isStore;
	}

	public synchronized void setStore(boolean isStore) {
		this.isStore = isStore;
	}

	public synchronized String getName() {
		return name;
	}

	public synchronized void setName(String name) {
		this.name = name;
	}

	public synchronized String getValue() {
		return value;
	}

	public synchronized void setValue(String value) {
		this.value = value;
	}

	public synchronized boolean isAnalyzed() {
		return isAnalyzed;
	}

	public synchronized void setAnalyzed(boolean isAnalyzed) {
		this.isAnalyzed = isAnalyzed;
	}
}
